skynet = require "skynet"
cluster = require "skynet.cluster"
log = require "log" 
socket = require "skynet.socket"

skynet.start(function ()


local agent = {}
local balance = 1
local protocol = "ws"
 local id = socket.listen("0.0.0.0", 9948)
 log.info(string.format("Listen websocket port 9948 protocol:%s", protocol))
 log.info("id=", id)
 socket.start(id, function(id, addr)
    log.info(string.format("accept client socket_id: %s addr:%s", id, addr))
         ---[[
         agent[balance] = skynet.newservice("test")
         skynet.send(agent[balance], "lua", id, protocol, addr)
         balance = balance + 1
         if balance > #agent then
             balance = 1
         end
         --]]
    --end)
     -- test echo client
     --service.new("websocket_echo_client", simple_echo_client_service, protocol)
end)
end)